﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TextBoxTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            byte[] bytes = new byte[] { 0x31,0x32,0x33,0x34,0x0D,0x0A,0x61,0x74};
            string str = "";
            if (comboBox1.SelectedIndex == 0) {
                str = Encoding.ASCII.GetString(bytes);
            } else {
                str = Encoding.GetEncoding("GB2312").GetString(bytes);
            }

            if(!str.Contains("\r\n") && str.Contains("\n")) {
                string[] strs = str.Split('\n');
                str = "";
                foreach (string s in strs) {
                    if (str != "")
                        str += "\r\n";
                    str += s;
                }
            }

            textBox1.Text = str;
        }
    }
}
